$(function () {
  //给登录按钮做点击事件
  $("#login").on("click", function () {
    //获取用户输入的信息
    const username = $("#username").val().trim();
    const password = $("#password").val().trim();
    $.post(
      "http://localhost:8080/api/v1/admin/user/login",
      {
        username,
        password,
      },
      function (res) {
        console.log(res);
        if (res.msg == "登录成功") {
          localStorage.setItem("token", res.token);
          location.assign("index.html");
        } else {
          console.log(res.msg);
        }
      }
    );
  });
});
